package com.xgk.boot.module.core.service.truck;

import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.xgk.boot.framework.common.pojo.PageResult;
import com.xgk.boot.framework.mybatis.core.query.LambdaQueryWrapperX;
import com.xgk.boot.module.core.controller.admin.truck.vo.TruckOrderOtherReqVO;
import com.xgk.boot.module.core.dal.entity.truck.TruckOrderLogDO;
import com.xgk.boot.module.core.dal.entity.truck.TruckOrderTrackDO;
import com.xgk.boot.module.core.dal.iservice.truck.TruckOrderTrackService;
import com.xgk.boot.module.core.dal.mapper.truck.TruckOrderTrackMapper;
import org.springframework.stereotype.Service;

/**
 * 订单物流跟踪 服务实现
 */
@Service
public class TruckOrderTrackServiceImpl extends ServiceImpl<TruckOrderTrackMapper, TruckOrderTrackDO> implements TruckOrderTrackService {


    public PageResult<TruckOrderTrackDO> pageOrderTrack(TruckOrderOtherReqVO orderOtherReqVO){
        if(orderOtherReqVO == null || StrUtil.isBlank(orderOtherReqVO.getOrderCode())){
            return new PageResult<>();
        }
        LambdaQueryWrapperX<TruckOrderTrackDO> boxWrapperX = new LambdaQueryWrapperX<>();
        boxWrapperX.eq(TruckOrderTrackDO::getOrderCode, orderOtherReqVO.getOrderCode());
        boxWrapperX.orderByDesc(TruckOrderTrackDO::getTimestamp);
        Page<TruckOrderTrackDO> page=new Page<>(orderOtherReqVO.getCurrent(),orderOtherReqVO.getPageSize());
        Page<TruckOrderTrackDO> pageRes = this.page(page, boxWrapperX);

        return new PageResult<>(pageRes.getRecords(), pageRes.getTotal(), orderOtherReqVO.getCurrent(), orderOtherReqVO.getPageSize());
    }

}